
check_style:
	find . -type f -exec grep foxitcloud.com {} \; -print

# Provision a machine without Vagrant

nv_provision:
	@echo "Run 'make provision_a2ucx' for provisioning single vagrant box..."

# Run following for 4box vagrant provisioning. Do vagrant ssh first

provision_database:
	sudo ./pre_provision.sh
#	sudo ./prepare_database.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/database.pp
	sudo ./provision_node_database.sh
#	sudo ./post_provision_node_database.sh

provision_platform:
	sudo ./pre_provision.sh
#	sudo ./prepare_platform.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/platform.pp
#	sudo ./provision_node_platform.sh
#	sudo ./post_provision_node_platform.sh

provision_worker:
	sudo ./pre_provision.sh
#	sudo ./prepare_worker.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/worker.pp
#	sudo ./provision_node_worker.sh
#	sudo ./post_provision_node_worker.sh

provision_cas:
	sudo ./pre_provision.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/cas.pp

provision_cmis:
	sudo ./pre_provision.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/cmis.pp
	sudo ./prepare_cmis.sh

provision_webapp:
	sudo ./pre_provision.sh
#	sudo ./prepare_webapp.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/webapp.pp

provision_mongo:
	sudo ./pre_provision.sh
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/mongo.pp
	sudo ./mongoinit-pro.sh

# Provision single vagrant box
provision_a2ucx:
	sudo ./pre_provision.sh
	sudo ./setup_swap.sh
	# sudo ./download_files.sh 
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/a2ucx.pp
	sudo ./provision.sh ..
	sudo ./post_provision.sh
# Provision nginx upstream site

provision_upstream:
	sudo ./pre_provision.sh
	sudo ./setup_swap.sh
	# sudo ./download_files.sh 
	sudo puppet apply -v --debug --modulepath=../puppet/modules ../puppet/manifests/balancing.pp

deploy_pcs:
	./p1_utils.sh -clear_download_cache
	@echo "--->Getting latest war/so files from dowload server to vagrant box..."
	sudo ./download_files.sh develop
	@echo "--->Restarting worker..."
	sudo service fxworker restart
	@echo "--->Restarting platform..."
	sudo service fxplatform restart
	@echo "--->Restarting tomcat..."
	sudo service tomcat restart
	@echo "--->Restarting cas..."
	sudo service fxcas restart

deploy_cwebtools:
	@echo "--->Getting latest war/so files from dowload server to vagrant box..."
	sudo ./download_cwebtools.sh
	@echo "--->Restarting tomcat..."
	sudo service tomcat restart

delete_index:
	curl -s -XDELETE http://localhost:9200/sm_index/
	curl -s -XDELETE "http://localhost:9200/.marvel-*"

clean_assets:
	@echo "--->clean the assets folder in foxitcloudapp, docoshareapp, formapp, foxitarchiveapp ..."
	cd /vagrant/webapp/foxitcloudapp/web/assets && ls|grep -v .git|xargs rm -rf
	cd /vagrant/webapp/docoshareapp/web/assets && ls|grep -v .git|xargs rm -rf
	cd /vagrant/webapp/formapp/web/assets && ls|grep -v .git|xargs rm -rf
	cd /vagrant/webapp/foxitarchiveapp/web/assets && ls|grep -v .git|xargs rm -rf
